package com.lc.util;

import com.guigu.mapper.TGetserialMapper;
import com.guigu.pojo.TGetserial;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Component
public class Getserial {

    @Resource
    private TGetserialMapper mapper;

    public  String returnId() {
        //格式yyyyMMdd001
        Date date=new Date();
        SimpleDateFormat sf=new SimpleDateFormat("yyyyMMdd");
        String format = sf.format(date);
        List<TGetserial> zlist = this.mapper.queryallgetserial();
        int z=zlist.size()+1;
        String w=String.format("%03d",z);
        this.mapper.insertgetserialByid(format.substring(0)+w);
        return format.substring(0)+w;
    }

   public String returnYDid(){
       //格式YD0001
       int ydid = this.mapper.ydgetserial();
       ydid+=1;
       String x="YD";
       String y=String.format("%04d",ydid);
       this.mapper.insertgetserialByid(x+y);
       return x+y;
   }

   public String returnSpid(){
        //格式Sp0001
       int spid = this.mapper.sPgetserial();
       spid+=1;
       String x="Sp";
       String y=String.format("%04d",spid);
       this.mapper.insertgetserialByid(x+y);
       return x+y;
   }
   public String returnJBid(){
        //JB001
       int jbid = this.mapper.JBgetserial();
       jbid+=1;
       String x="JB";
       String y=String .format("%04d",jbid);
       this.mapper.insertgetserialByid(x+y);
       return x+y;
   }


   public String returnNumfive(){
       //格式0001
       int fivenum = this.mapper.selectgetserialfivenum();
       fivenum+=1;
       String y=String.format("%04d",fivenum);
       this.mapper.insertgetserialByid(y);
       return y;
   }

    public String returnNumfour(){
        //格式0001
        int fivenum = this.mapper.selectgetserialfournum();
        fivenum+=1;
        String y=String.format("%04d",fivenum);
        this.mapper.insertgetserialByid(y);
        return y;
    }



}
